home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2307 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: res.com!usenet
  2. From: danlynes@res.com
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Segmentation fault at return statement. Can't figure out ....
  5. Date: 20 Jan 1996 10:40:35 GMT
  6. Organization: RES Online
  7. Message-ID: <4dqgr3$626@clare.res.com>
  8. References: <4dm2n1$egk@murphy.servtech.com>
  9. Reply-To: danlynes@res.com
  10. NNTP-Posting-Host: di007.res.com
  11. X-Newsreader: IBM NewsReader/2 v1.2.5
  12.  
  13. In <4dm2n1$egk@murphy.servtech.com>, Avijit Dasgupta <avi@servtech.com> writes:
  14.  
  15. >83: return(999); <----- Segmentation fault at this stmt.
  16. >}
  17. >
  18. >Running dbx I get these error messages:
  19. >
  20. >(dbx) where
  21. >=> [1] test( ) at line 83
  22. >dbx: bad data address
  23. >dbx fetch at 0x697075a4 failed - I/O error
  24. >dbx : attempt to read stack failed - bad frame pointer
  25. >(dbx)
  26. >
  27. >I can't figure out, bcoz this function gets called multiple times and
  28. >fails only after a fixed X times ... Any Help ? 
  29.  
  30. My guess would be that you're allocating some memory that you're 
  31. not freeing up, when returning from the function.  So, after so 
  32. many calls to it, your stack gets filled up, and refuses to 
  33. continue running.  i.e.  You have a stack overflow error.  Try 
  34. proofing your code, to see if there's any memory you're 
  35. forgetting to deallocate, either by by explicitly allocated 
  36. memory, or implicitly allocated memory.  One common cause, is 
  37. that some C programmers forget that strdup implicitly calls 
  38. malloc, and as a result, forget to deallocate the allocated 
  39. memory.
  40.  
  41. However, you might have other problems specific to UNIX.  In 
  42. which case, I'm afraid I can't be of any help, but you might look
  43. to comp.unix.programmer for solutions in that case.
  44.  
  45. +------------------------------------------------------+
  46. !  OS/2         - The Champion of Operating Systems    !
  47. !  Enitharmon/2 - A Powerful BBS Package               !
  48. !  What a great pair!               danlynes@res.com   !
  49. !  www.res.com/~danlynes/index.html                    !
  50. !  www.res.com/~danlynes/Enitharmon!2/index.html       !
  51. !  The Enitharmon Beta project is now under way.       !
  52. !  To subscribe to the mailing list, send e-mail to    !
  53. !  danlynes@res.com or daniel.lynes@ideasnet.com       !
  54. +------------------------------------------------------+
  55.  
  56.